package riofrio.examples;

import java.util.List;
import riofrio.TreeNode;
import static riofrio.TreeNode.with;
import riofrio.BreadthFirstWalk;

/**
 *
 * @author Victor Hugo Herrera Maldonado
 */
public class Searching {
    
    public static void main(String[] args) {
        TreeNode<Integer> root=with(8)
            .children(
                with(7)
                    .childrenWith(4, 3), 
                with(6)
                    .childrenWith(9, 18, 5)
            );
        List<TreeNode<Integer>> evenNumbers=new BreadthFirstWalk<>(root).searchAll((node)->{
            return  node.getContent() % 2 == 0;
        });
        evenNumbers.stream().forEach((node) -> {
            System.out.printf("EvenNumber: %d%n", node.getContent());
        });
    }
    
}
